/*
 * @Author: shenya
 * @Date: 2023-09-08 15:45:14
 * @Description: 用户内容option
 */
import {
  COMMENT_STATUS_LIST,
  VOTE_STATUS_DIC,
  VOTE_RESULT_DIC,
  VOTE_TYPE_DIC,
  VOTE_STATUS,
  CUSTOMER_TYPE_LIST,
  AUTHENTICATION_STATUS_LIST,
} from '@/const/type';
//列表
export const tableOption = (isview, type) => {
  return {
    ...window.$crudMixins.tableOptions,
    selection: true,
    addBtn: false,
    editBtn: false,
    delBtn: false,
    menuWidth: 200,
    column: [
      {
        label: '内容编号',
        prop: 'id',
      },
      {
        label: isview === false ? '官方账号' : '用户账号',
        prop: 'user',
        slot: true,
        width: 120,
      },
      {
        label: '话题名称',
        prop: 'topicNames',
        search: (isview && !type) || !isview,
        overHidden: true,
      },
      {
        label: '内容标签',
        prop: 'labelIdStr',
        hide: isview,
        slot: true,
        overHidden: true,
      },
      {
        label: '动态标题',
        prop: 'title',
        hide: isview,
        overHidden: true,
      },
      {
        label: '动态内容',
        prop: 'content',
        overHidden: true,
        search: true,
      },
      {
        label: '发起投票',
        prop: 'voteStatus',
        search: !type || !isview,
        type: 'select',
        hide: type || isview,
        value: '0',
        dicData: [
          // {
          //   label: '全部',
          //   value: '',
          // },
          {
            label: '是',
            value: '1',
          },
          {
            label: '否',
            value: '0',
          },
        ],
      },
      {
        label: '阅读',
        prop: 'readQty',
      },
      {
        label: '评论',
        prop: 'commentQty',
      },
      {
        label: '用户昵称',
        prop: 'userNickname',
        search: true,
        searchIsShow: true,
        hide: true,
      },
      {
        label: '创建时间',
        prop: 'createTime',
        search: true,
        type: 'datetime',
        searchRange: true,
        format: 'yyyy-MM-dd HH:mm:ss',
        valueFormat: 'yyyy-MM-dd HH:mm:ss',
        width: 160,
      },
      {
        label: '是否精选',
        prop: 'choiceFlag',
        type: 'switch',
        search: true,
        slot: true,
        dicData: [
          {
            label: '已精选',
            value: '1',
          },
          {
            label: '未精选',
            value: '0',
          },
        ],
      },
      {
        label: '是否屏蔽',
        prop: 'shieldFlag',
        search: true,
        type: 'switch',
        slot: true,
        dicData: [
          {
            label: '已屏蔽',
            value: '1',
          },
          {
            label: '未屏蔽',
            value: '0',
          },
        ],
      },
    ],
  };
};
//评论
export const commmentOption = () => {
  return {
    ...window.$crudMixins.tableOptions,
    addBtn: false,
    editBtn: false,
    delBtn: false,
    menuWidth: 60,
    column: [
      {
        label: '内容编号',
        prop: 'relativeId',
      },
      {
        label: '评论编号',
        prop: 'code',
        search: true,
      },
      {
        label: '用户昵称',
        prop: 'createBy',
        search: true,
      },
      {
        label: '用户编号',
        prop: 'creator',
        search: true,
      },
      {
        label: '评论详情',
        prop: 'msg',
        overHidden: true,
      },
      {
        label: '回复评论编号',
        prop: 'parentCode',
        width: 120,
      },
      {
        label: '评论时间',
        prop: 'createTime',
        width: 160,
      },
      {
        label: '状态',
        prop: 'status',
        width: 80,
        dicData: COMMENT_STATUS_LIST,
      },
    ],
  };
};
//灌水账号
export const accountOption = () => {
  return {
    ...window.$crudMixins.tableOptions,
    addBtn: false,
    cellBtn: false,
    addRowBtn: true,
    saveBtn: false,
    cancelBtnText: '删除行',
    columnBtn: false,
    menuWidth: 120,
    delBtn: false,
    editBtn: false,
    rowKey: 'ids',
    column: [
      {
        label: '评论内容',
        prop: 'commentContent',
        cell: true,
        maxlength: 255,
        rules: [
          {
            required: true,
            message: '请输入评论内容',
            trigger: 'blur',
          },
        ],
      },
      {
        label: '灌水用户',
        prop: 'userName',
        cell: true,
        disabled: true,
        rules: [
          {
            required: true,
            message: '请输入灌水用户',
            trigger: 'blur',
          },
        ],
      },
    ],
  };
};
export const formOption = (status) => {
  return {
    submitBtn: false,
    emptyBtn: false,
    detail: true,
    column: [
      {
        label: '图片/视频',
        detail: true,
        prop: 'files',
        type: 'upload',
        fileSize: 50 * 1024, // 写在这里直接拦截没有提示
        listType: 'picture-card',
        propsHttp: {
          name: 'hash',
          url: 'key',
        },
        oss: 'qiniu',
        tip: '最多可上传30个图片/视频',
        row: true,
        span: 24,
        accept: '.mp4, .mpeg, .WMV, .mov, .jpg, .png, .jpeg, .webp, .heic',
        limit: 30,
        drag: true,
        multiple: true,
        rules: [
          {
            required: true,
            message: '请上传宣传图片/视频',
            trigger: 'blur',
          },
        ],
      },
      {
        label: '发起投票',
        prop: 'voteStatus',
        type: 'select',
        row: true,
        border: false,
        dicData: VOTE_STATUS_DIC,
        value: '1',
      },
      {
        label: '类型',
        prop: 'voteType',
        type: 'select',
        display: status === VOTE_STATUS.YES,
        row: true,
        border: false,
        dicData: VOTE_TYPE_DIC,
        value: '1',
      },
      {
        label: '投票结果',
        prop: 'voteResultType',
        type: 'select',
        row: true,
        display: status === VOTE_STATUS.YES,
        border: false,
        dicData: VOTE_RESULT_DIC,
        value: '1',
      },
      {
        label: '投票结束时间',
        prop: 'voteEndTime',
        row: true,
        display: status === VOTE_STATUS.YES,
        border: false,
      },
      {
        label: '标题',
        prop: 'voteTitle',
        row: true,
        display: status === VOTE_STATUS.YES,
        border: false,
      },
      {
        label: '',
        prop: 'votePoints',
        formslot: true,
        row: true,
        span: 24,
        display: status === VOTE_STATUS.YES,
        border: false,
      },

      {
        label: '结语',
        prop: 'voteDescription',
        row: true,
        span: 24,
        display: status === VOTE_STATUS.YES,
        border: false,
        formslot: true,
      },
    ],
  };
};
///用户信息
export const userInfoOption = () => {
  return {
    addBtn: false,
    editBtn: false,
    delBtn: false,
    detail: true,
    column: [
      {
        label: '用户头像',
        prop: 'avatar',
        type: 'upload',
        listType: 'picture-img',
        span: 12,
        fileSize: 10 * 1024,
        propsHttp: {
          name: 'hash',
          url: 'key',
        },
        fileType: 'img', //img/video/audio
        // action: 'http://upload-z2.qiniup.com',
        oss: 'qiniu',
        cropperOption: {
          enlarge: 2,
          fixed: true,
          fixedNumber: [0.83, 1],
        },
        tip: '请上传jpg/png/jpeg/webp/heic类型的文件，最大可上传10M',
        accept: '.jpg,.png,.jpeg,.webp,.heic',
        limit: 1,
        hide: true,
        viewDisplay: true,
      },
      {
        fixed: true,
        label: '用户编号',
        prop: 'code',
        search: true,
        width: 160,
      },
      {
        type: 'input',
        label: '用户昵称',
        prop: 'nickname',
        search: true,
        rules: [
          {
            required: true,
            message: '请输入用户名',
          },
          {
            min: 3,
            max: 20,
            message: '长度在 3 到 20 个字符',
            trigger: 'blur',
          },
        ],
        width: 160,
        overHidden: true,
      },
      {
        type: 'input',
        label: '手机号',
        prop: 'phone',
        search: true,
        width: 160,
        rules: [
          {
            min: 11,
            max: 11,
            required: true,
            message: '长度在 11 个字符',
            trigger: 'blur',
          },
        ],
      },
      {
        label: '注册时间',
        prop: 'registerTime',
        type: 'datetime',
        width: 160,
        format: 'yyyy-MM-dd HH:mm:ss',
        valueFormat: 'yyyy-MM-dd HH:mm:ss',
        search: true,
        searchRange: true,
      },
      {
        type: 'select',
        label: '实名认证',
        prop: 'authFlag',
        dicData: AUTHENTICATION_STATUS_LIST,
      },
      {
        label: '姓名',
        prop: 'name',
        hide: true,
      },
      {
        label: '身份证号',
        prop: 'idCard',
        hide: true,
      },
      {
        type: 'select',
        label: '性别',
        prop: 'sex',
        dicUrl: '/admin/dict/type/sex',
      },
      {
        label: '生日',
        prop: 'birth',
        width: 120,
      },
      {
        type: 'input',
        label: '当前城市',
        prop: 'district',
        overHidden: true,
        width: 130,
        rules: [
          {
            min: 2,
            max: 64,
            required: true,
            message: '请输入姓名',
            trigger: 'blur',
          },
        ],
      },
      {
        label: '注册渠道',
        prop: 'registerChannel',
        search: true,
        // dicUrl: '/admin/dict/type/channel_type',
      },
      {
        label: '平台类型',
        prop: 'deviceCode',
      },
      {
        label: '推广渠道',
        prop: 'channel',
        width: 120,
        overHidden: true,
        span: 12,
      },
      {
        label: '广告版位',
        prop: 'channelKey',
        width: 120,
        overHidden: true,
        span: 12,
      },
      {
        label: '类型',
        prop: 'type',
        type: 'select',
        search: true,
        rules: [
          {
            required: true,
            message: '请选择用户类型',
            trigger: 'blur',
          },
        ],
        dicData: CUSTOMER_TYPE_LIST,
      },
      {
        label: '状态',
        prop: 'lockFlag',
        type: 'select',
        rules: [
          {
            required: true,
            message: '请选择状态',
            trigger: 'blur',
          },
        ],
        dicData: [
          {
            label: '有效',
            value: '0',
          },
          {
            label: '锁定',
            value: '9',
          },
        ],
      },
      {
        prop: 'description',
        type: 'textarea',
        label: '个人简介',
        minRows: 7,
        hide: true,
        span: 24,
      },
      // {
      //   label: '用户标签',
      //   prop: 'labelList',
      //   type: 'select',
      //   dicUrl: '/app/appuser/label/list',
      //   multiple: true,
      //   hide: true,
      //   props: {
      //     label: 'name',
      //     value: 'id',
      //   },
      // },
      {
        label: '用户标签',
        prop: 'labelList',
        slot: true,
        hide: true,
      },
      {
        label: '备注',
        prop: 'remark',
        type: 'textarea',
        maxlength: 100,
        minRows: 7,
        showWordLimit: true,
        span: 24,
        hide: true,
      },
    ],
  };
};
